import aixos from 'axios'

export class ApiFetch {
    constructor(endPoint, verb = 'post') {
        this.endPoint = endPoint
        this.verb = verb
    }

    async fetch(params, config = {}) {
        const v = this.verb
        const e = this.endPoint
        // console.log(aixos.)
        const resp = await aixos[v](e, params, config)
        return resp
    }

    async fetchByFD(params, config = {}) {
        const fm = new FormData()
        const v = this.verb
        const e = this.endPoint
        for (let [key, value] of Object.entries(params)) {
            fm.append(key, value)
        }
        const resp = await aixos[v](e, fm, config)
        return resp
    }
}

